<template>
  <footer class="footer-nav">
    <!-- 导航项列表 -->
    <div 
      v-for="(item, index) in navItems" 
      :key="index"
      class="nav-item"
      @click="handleNavClick(item)"
    >
      <div class="nav-text">{{ item.name }}</div>
    </div>
  </footer>
</template>

<script>
export default {
  name: 'BottomNav',
  props: {
    // 导航项配置
    navItems: {
      type: Array,
      default: () => []
    },
    // 固定定位
    fixed: {
      type: Boolean,
      default: true
    }
  },
  methods: {
    handleNavClick(item) {
      // 更新激活状态
    //   this.navItems.forEach(nav => {
    //     nav.active = nav.text === item.text;
    //   });
      
      // 触发路由跳转或自定义事件
      if (item.url) {
        this.$router.push(item.url);
      }
      this.$emit('nav-click', item);
    }
  }
}
</script>

<style scoped>
.footer-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 56px;
  background-color: #fff;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  position: relative;
  z-index: 99;
}

/* 固定定位样式 */
.footer-nav.fixed {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5px 0;
  cursor: pointer;
  color: #666;
  transition: all 0.3s;
}

.nav-item.active {
  color: #409eff;
}

.nav-icon {
  position: relative;
  font-size: 20px;
  margin-bottom: 3px;
}

.nav-text {
  font-size: 12px;
}

.nav-badge {
  position: absolute;
  top: -6px;
  right: -10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  border-radius: 8px;
  background-color: #f56c6c;
  color: #fff;
  font-size: 10px;
  padding: 0 4px;
}

/* 移动端适配 */
@media (max-width: 768px) {
  .footer-nav {
    height: 50px;
  }
  .nav-icon {
    font-size: 18px;
  }
  .nav-text {
    font-size: 10px;
  }
}
</style>
